package com.mdsoft.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;

import com.mdsoft.dao.PlanDao;
import com.mdsoft.po.Group;
import com.mdsoft.po.User;
import com.mdsoft.service.ChooseService;
import com.mdsoft.service.GroupService;
import com.mdsoft.service.PlanService;
import com.opensymphony.xwork2.ActionSupport;

public class PlanAction extends ActionSupport implements RequestAware{
	private static final long serialVersionUID = 6460572260207838154L;
	
	private PlanService planService;
	
	private ChooseService chooseService;

	private GroupService groupService;
	
	private Map<String, Object> request;
	
	public String result() {
		String result = SUCCESS;
		int plan = planService.getPlan();
		switch (plan) {
		case PlanDao.PLAN_WAIT_SET:
			result = "wait_set";
			break;
		case PlanDao.PLAN_WAIT_CHOOSE:
			
			List<User> users = chooseService.getNoCompeletedUser();
			request.put("users", users);
			
			result = "wait_choose";
			break;
		case PlanDao.PLAN_WAIT_GROUP:
			result = "wait_group";
			break;
		case PlanDao.PLAN_COMPLETE:
			
			List<Group> groups = groupService.getAll();
			request.put("groups", groups);
			result = SUCCESS;	
			break;
		}
		return result;
		
	}

	public PlanService getPlanService() {
		return planService;
	}

	public void setPlanService(PlanService planService) {
		this.planService = planService;
	}

	@Override
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	public ChooseService getChooseService() {
		return chooseService;
	}

	public void setChooseService(ChooseService chooseService) {
		this.chooseService = chooseService;
	}

	public GroupService getGroupService() {
		return groupService;
	}

	public void setGroupService(GroupService groupService) {
		this.groupService = groupService;
	}

	
	
}
